#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "place.h"
#include "searchresult.h"

#include <QFile>
#include <QMainWindow>
#include <QStringList>
#include <QStringListModel>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    
private slots:
    void errorOccured(const QString & error);
    void on_pbSearchRestaurant_clicked();
    void on_pbSavePlaceDetailsResult_clicked();
    void searchPlacesNearbyLocation(const QString &location);
    void searchPlaceDetails(const QString & place_id);
    void updatePlaceDetails(const Place &place_detail);

    void showSearchHistoryDialog();
    void editSettings();
private:

    //Handle write to json file
    QVariant loadJsonFileRaw(QFile &jsonFile);
    void     clearJsonFileRaw(QFile &jsonFile);

    //Handle search result
    QList<SearchResult*> getSearchResults(QFile &jsonFile);
    void                 addSearchResult(QFile &jsonFile, SearchResult *adding_result);
    void                 clearSearchResult(QList<SearchResult*> searchResults);

    QStringList          getPlaceDetail() const;

private:
    Ui::MainWindow *ui;
    class  RestaurantDataManager * m_pDataManager;


    //The list model will be display in QListView
    QStringListModel *model;

    //Setting variable
    QString m_authorName;
    QString m_appName;
    QString m_strApiKey;
    uint    m_maxNumberOfDisplayPlaces;

    QString m_savedFilePath;
    QString m_savedFileName;
};

#endif // MAINWINDOW_H
